import tkinter as tk
import tkinter.filedialog as fd
from upload import upload_tbl_picture_file


result_dict = {'file_path':""} 

def getFileDir():
    file_path = fd.askopenfilename(filetypes = [("图片",("*.jpg","*.png","*.webp"))]) 
    result_dict['file_path'] = file_path    
    label_tip['text'] = "upload file path is"
    text_path.insert(1.0, result_dict['file_path'])

def upload():
    upload_tbl_picture_file.insert_picture_to_tbl_picture_file(result_dict['file_path'])

def export_excel():
    # uplode_and_query_file.export_tbl_picture_file_to_excel()
    pass

root = tk.Tk() 
root.title('kkomia_demo') 
root.geometry('500x300')

label_tip = tk.Label(root, text = "please select the upload file", width = 30, height = 0)
text_path = tk.Text(root, width= 200, height=100)
btn_select = tk.Button(root, text = "select file", command = getFileDir) 
btn_upload = tk.Button(root, text = "upload file", command = upload)
btn_export_excel = tk.Button(root, text = "export excel", command = export_excel)

# display
btn_select.pack()
btn_upload.pack()
btn_export_excel.pack()
label_tip.pack() 
text_path.pack()

    
root.mainloop() 
    

# print(result_dict['file_path'])